package com.zzyl.entity;

import com.zzyl.vo.CustomerReservationVo;
import lombok.Data;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.List;

@Data
public class CountByTimeMethod {

    public List<CustomerReservationVo> count(List<CustomerReservationVo> list , LocalDate ld) {
        List<CustomerReservationVo> customerReservationVoList = new ArrayList<>();
        LocalDateTime ldt = LocalDateTime.of(ld, LocalTime.of(8,0));
        for(int i = 0; i < 21; i++) { //todo 21
            CustomerReservationVo customerReservationVo = new CustomerReservationVo();
            customerReservationVo.setTime(ldt);
            if (customerReservationVo.getTime().isBefore(LocalDateTime.now())){
                for (int j = 0; j < list.size(); j++) {
                    CustomerReservationVo tempVo = list.get(j);
                    if (tempVo.getTime().equals(customerReservationVo.getTime())){
                        customerReservationVo.setCount(6-tempVo.getCount());
                    }else
                        customerReservationVo.setCount(6);
                }
                customerReservationVoList.add(customerReservationVo);
            }
            ldt = ldt.plusMinutes(30);
        }
        return customerReservationVoList;
    }

}
